window.mb = window.mb || {}

mb.currentMenu = function (selector, cb) {
  const menus = $(selector)

  const { pathname } = window.location
  console.log("%c Line:7 🍻 pathname", "color:#ffdd4d", pathname)
  if (pathname === "/") {
    menus.eq(0).addClass("on")
    return
  }

  const fun = e => e.getAttribute("href") === pathname ? "add" : "remove"
  menus.each((i, el) => el.classList[fun(el)]("on"))

  cb && cb()
}

mb.home = {
  tab: function (selector, cb) {
    $(selector).click(function () {
      const tabId = $(this).data('tab')
      $(this).addClass('on').siblings().removeClass('on')

      const temp = $('[id=' + tabId + ']')
      console.log("%c Line:26 🥖 temp", "color:#93c0a4", temp)
      const temps = temp.parent().find('[id^=' + tabId.split('-')[0] + '-]')
      temps.each((i, el) => $(el).hide())
      temp.show()
    })
  }
}
